import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

plt.rcParams['font.sans-serif'] = ['SimHei']  # 解决中文乱码问题
df = pd.read_excel('../source/体温.xls')
x = df['日期']
y = df['体温']
# fig = plt.figure(figsize=(5, 3), facecolor='yellow')
plt.plot(x, y, color='m', linestyle='-', marker='o', mfc='w')  # mfc为填充颜色
plt.xlabel('2020年2月')
plt.ylabel('基础体温')
dates = ['1日', '2日', '3日', '4日', '5日'
	, '6日', '7日', '8日', '9日', '10日'
	, '11日', '12日', '13日', '14日', '15日']
plt.xticks(range(1, 16), dates)
plt.yticks(np.arange(35.4, 38, 0.2))

for a, b in zip(x, y):
	plt.text(a, b + 0.15, '%.1f' % b, ha='center', va='bottom', fontsize=9)

plt.title('14天基础体温曲线图', fontsize='18')
plt.legend(('基础体温',), loc='upper left', fontsize=10)

plt.annotate('最高体温', xy=(9, 37.1), xytext=(10.5, 37.1), xycoords='data', arrowprops=dict(facecolor='r', shrink=0.05))
plt.subplots_adjust(left=0.2, right=0.9, top=0.9, bottom=0.2)
# 如果只显示图片,坐标轴及标题都不显示
# plt.subplots_adjust(left=0, right=1, top=1, bottom=0, hspace=0.1,wspace=0.1)
# plt.tick_params(bottom=False, left=True, right=True, top=True)
plt.rcParams['xtick.direction'] = 'in'
plt.rcParams['ytick.direction'] = 'in'
plt.show()
